
/* Includes ------------------------------------------------------------------*/
#include "ph.h"
#include "adc-eiri.h"
#include "usart.h"

double GET_PH_Value(void)
{
    uint16_t temp = 0;
    double value;
    
    if(__HAL_ADC_GET_FLAG(&hadc1, ADC_FLAG_EOC) != RESET ) 
    {
        __HAL_ADC_CLEAR_FLAG(&hadc1, ADC_FLAG_EOC);
        temp = HAL_ADC_GetValue(&hadc1);       
    }
    
    value = (double)temp*1.02*3.3/4096.0; //calibration adc
    value = -5.64 * value + 16.39;
    return value;
}


